package cn.tedu._05mvcboot01.controller;

import cn.tedu._05mvcboot01.pojo.dto.UserRegDTO;
import com.sun.net.httpserver.HttpServer;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Controller注解：
 * 标识当前类为控制类，用于接受客户端请求
 */
@Controller
public class UserController {
    @RequestMapping("/v1/users/login")
    @ResponseBody
    public String login(){
        return "恭喜你，登录成功！";
    }
    @RequestMapping("/v1/users/reg1")
    @ResponseBody
    public String reg1(HttpServletRequest request){
        String username = request.getParameter("username");
        String passwprd = request.getParameter("password");
        return username +"---"+passwprd;

    }
    @RequestMapping("/v1/users/reg2")
    @ResponseBody
    public String reg2(String username,String password){
        return username +"---"+password;
    }
    @RequestMapping("v1/users/reg3")
    @ResponseBody
    public String reg3(UserRegDTO userRegDTO){
        String username = userRegDTO.getUsername();
        String password = userRegDTO.getPassword();
        return username +"***"+password;
    }
}




























